// Copyright: Personal possession of Nguyen Minh Kha
// Decription: This class use to manage user input from keyboard and mouse
// Date time: 09:30AM, 07/08/2011(mm/dd/yyyy)
// License: free source
// Version: 1.0
// Writer: Nguyen Minh Kha
// Sample usage:
//   Control control;
//   ...
//   /*in game loop*/
//   control.CatchEvent();

#ifndef GAMEFRAMEWORK_CONTROL_H_
#define GAMEFRAMEWORK_CONTROL_H_

#include <Windows.h>
#include "resource.h"
#include <dinput.h>

#include "log.h"
#include "controllable_manager.h"

class Control
{
  //
  // Enum
  //
private:
  enum CONTROL_CLASS {
    ONE,
    TWO,
    THREEE
  };
  //
  // Static instance
  //
public:
  static Control *control;
  //
  // Constructor, Destructor
  // 
public:
  Control(void);
  ~Control(void);

  //
  // Method
  //
public:
  bool Init(HINSTANCE hInstance, HWND hWnd);
  void Acquire();
  void Release();
  void CatchEvent();
private:
  void Control_One();
  void Control_Two();
  void Control_Three();
  //
  // Data member
  //
private:
  CONTROL_CLASS mode;
  HWND hWnd;
  HRESULT hResult; // direct input result
  // DirectInput interface
  LPDIRECTINPUT8 dinput;
  LPDIRECTINPUTDEVICE8 deviceKeyboard;
  LPDIRECTINPUTDEVICE8 deviceMouse;
  DIPROPDWORD dipdw; // key buffer
  LPDIDEVICEOBJECTDATA keyEvents;
  DWORD numberOfKeyEvent;
  DISALLOW_COPY_AND_ASSIGN(Control);
};
#endif // GAMEFRAMEWORK_CONTROL_H_
